package com.nuyoah.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nuyoah.entity.Registration;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xiaoming
 * @since 2024-03-26
 */
public interface RegistrationMapper extends BaseMapper<Registration> {

    default boolean existsByUserAndActivity(Long userId, Long activityId) {
        QueryWrapper<Registration> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId)
                .eq("activity_id", activityId);
        return selectCount(queryWrapper) > 0;
    }

    List<Registration> getByActivityId(Long id);

}
